﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using MySql.Data.MySqlClient;

namespace gestionClinica.conexion
{
    public class Conexion
    {
        private string cadena;
        private MySqlConnection conn;

        public Conexion()
        {
            cadena = "Server=localhost; Database=clinica;User id=root";
            conn = new MySqlConnection(cadena);
        }

        public string conectar()
        {
            try
            {
                conn.Open();
                return "ok";
            }
            catch (MySqlException e)
            {
                return e.Message;
            }

        }

        public string desconectar()
        {
            try
            {
                conn.Close();
                return "ok";
            }
            catch (MySqlException e)
            {
                return e.Message;
            }

        }


        public MySqlConnection Conn
        {
            get { return conn; }
            set { conn = value; }
        }
        
    }
}
